using System;
using System.Collections.Generic;

namespace IQIGame.Onigao.Framework
{
    public class SOutputStream : IDisposable
    {
#if UNITY_EDITOR
        ~SOutputStream()
        {
            if (UnityEditor.EditorApplication.isPlaying)
            {
                if (_buffer != null)
                {
                    LogGame.LogError("SOutputStream is not be dispose!!!");
                }
            }
        }
#endif


        private SiByteBuffer _buffer;

        public SOutputStream()
        {
            _buffer = SiByteBuffer.Allocate(32);
        }

        public SOutputStream(int capacity)
        {
            _buffer = SiByteBuffer.Allocate(capacity);
        }

        public void WriterIndex(int index)
        {
            _buffer.WriterIndex = index;
        }

        public void WriteByte(byte value)
        {
            _buffer.WriteByte(value);
        }

        public int Size
        {
            get
            {
                return _buffer.Size;
            }
        }

        public int Capacity
        {
            get
            {
                return _buffer.Capacity;
            }
        }

        public void SetInt(int index, int value)
        {
            _buffer.SetInt(index, value);
        }

        public byte[] Buf
        {
            get
            {
                return _buffer.Buf;
            }
        }

        public byte[] ToByteArray()
        {
            return _buffer.ToByteArray();
        }

        public void Write_short(short value)
        {
            _buffer.Write_short(value);
        }

        public void Write_int(int value)
        {
            _buffer.Write_int(value);
        }

        public void Write_intArr(int[] value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            int length = value.Length;
            _buffer.WriteSize((uint)length, SType.LIST);
            if (length > 0)
            {
                for (int i = 0; i < length; i++)
                {
                    _buffer.Write_int(value[i]);
                }
            }
        }

        public void Write_long(long value)
        {
            _buffer.Write_long(value);
        }

        public void Write_byte(sbyte value)
        {
            _buffer.Write_byte(value);
        }

        public void Write_boolean(bool value)
        {
            _buffer.Write_boolean(value);
        }

        public void Write_float(float value)
        {
            _buffer.Write_float(value);
        }

        public void Write_double(double value)
        {
            _buffer.Write_double(value);
        }

        public void Write_ubyte(byte value)
        {
            _buffer.Write_ubyte(value);
        }

        public void Write_ushort(ushort value)
        {
            _buffer.Write_ushort(value);
        }

        public void Write_uint(uint value)
        {
            _buffer.Write_uint(value);
        }

        public void Write_bytes(byte[] value)
        {
            _buffer.Write_bytes(value);
        }

        public void Write_bytes_span(Span<byte> value)
        {
            _buffer.Write_bytes_span(value);
        }

        public void Write_string(string value)
        {
            _buffer.Write_string(value);
        }

        public void Write_pod(IPOD value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteByte(SType.POD);
            _buffer.EnsureWrite(4);// 占位4个字节,后续获取长度后再赋值
            _buffer.WriterIndex += 4;
            int index = _buffer.WriterIndex;
            value.Serial(this);
            int length = _buffer.WriterIndex - index;
            _buffer.SetInt(index - 4, length);// 计算长度后写入原来占位的字节
        }

        public void Write_list_pod<T>(List<T> list) where T : IPOD
        {
            if (list == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)list.Count, SType.LIST);
            if (list.Count > 0)
            {
                foreach (IPOD pod in list)
                {
                    Write_pod(pod);
                }
            }
        }

        public void Write_map_pod_pod<K, V>(Dictionary<K, V> map) where K : IPOD where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, V> entry in map)
                {
                    Write_pod(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Clear()
        {
            _buffer.Clear();
        }

        public void Dispose()
        {
            if (_buffer != null)
            {
                _buffer.Dispose();
                _buffer = null;
            }
        }



        #region code gen


        public void Write_map_boolean_boolean(Dictionary<bool, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, bool> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_boolean_byte(Dictionary<bool, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, sbyte> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_boolean_ubyte(Dictionary<bool, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, byte> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_boolean_short(Dictionary<bool, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, short> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_boolean_ushort(Dictionary<bool, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, ushort> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_boolean_int(Dictionary<bool, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, int> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_boolean_uint(Dictionary<bool, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, uint> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_boolean_float(Dictionary<bool, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, float> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_boolean_double(Dictionary<bool, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, double> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_boolean_long(Dictionary<bool, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, long> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_boolean_string(Dictionary<bool, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, string> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_boolean_bytes(Dictionary<bool, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<bool, byte[]> entry in value)
                {
                    _buffer.Write_boolean(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_byte_boolean(Dictionary<sbyte, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, bool> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_byte_byte(Dictionary<sbyte, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, sbyte> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_byte_ubyte(Dictionary<sbyte, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, byte> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_byte_short(Dictionary<sbyte, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, short> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_byte_ushort(Dictionary<sbyte, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, ushort> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_byte_int(Dictionary<sbyte, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, int> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_byte_uint(Dictionary<sbyte, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, uint> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_byte_float(Dictionary<sbyte, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, float> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_byte_double(Dictionary<sbyte, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, double> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_byte_long(Dictionary<sbyte, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, long> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_byte_string(Dictionary<sbyte, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, string> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_byte_bytes(Dictionary<sbyte, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<sbyte, byte[]> entry in value)
                {
                    _buffer.Write_byte(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_boolean(Dictionary<byte, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, bool> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_byte(Dictionary<byte, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, sbyte> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_ubyte(Dictionary<byte, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, byte> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_short(Dictionary<byte, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, short> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_ushort(Dictionary<byte, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, ushort> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_int(Dictionary<byte, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, int> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_uint(Dictionary<byte, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, uint> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_float(Dictionary<byte, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, float> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_double(Dictionary<byte, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, double> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_long(Dictionary<byte, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, long> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_string(Dictionary<byte, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, string> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_bytes(Dictionary<byte, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte, byte[]> entry in value)
                {
                    _buffer.Write_ubyte(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_short_boolean(Dictionary<short, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, bool> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_short_byte(Dictionary<short, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, sbyte> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_short_ubyte(Dictionary<short, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, byte> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_short_short(Dictionary<short, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, short> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_short_ushort(Dictionary<short, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, ushort> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_short_int(Dictionary<short, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, int> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_short_uint(Dictionary<short, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, uint> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_short_float(Dictionary<short, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, float> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_short_double(Dictionary<short, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, double> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_short_long(Dictionary<short, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, long> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_short_string(Dictionary<short, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, string> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_short_bytes(Dictionary<short, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<short, byte[]> entry in value)
                {
                    _buffer.Write_short(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_ushort_boolean(Dictionary<ushort, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, bool> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_ushort_byte(Dictionary<ushort, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, sbyte> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_ushort_ubyte(Dictionary<ushort, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, byte> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_ushort_short(Dictionary<ushort, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, short> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_ushort_ushort(Dictionary<ushort, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, ushort> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_ushort_int(Dictionary<ushort, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, int> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_ushort_uint(Dictionary<ushort, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, uint> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_ushort_float(Dictionary<ushort, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, float> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_ushort_double(Dictionary<ushort, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, double> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_ushort_long(Dictionary<ushort, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, long> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_ushort_string(Dictionary<ushort, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, string> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_ushort_bytes(Dictionary<ushort, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<ushort, byte[]> entry in value)
                {
                    _buffer.Write_ushort(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_int_boolean(Dictionary<int, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, bool> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_int_byte(Dictionary<int, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, sbyte> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_int_ubyte(Dictionary<int, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, byte> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_int_short(Dictionary<int, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, short> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_int_ushort(Dictionary<int, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, ushort> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_int_int(Dictionary<int, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, int> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_int_uint(Dictionary<int, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, uint> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_int_float(Dictionary<int, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, float> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_int_double(Dictionary<int, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, double> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_int_long(Dictionary<int, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, long> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_int_string(Dictionary<int, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, string> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_int_bytes(Dictionary<int, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<int, byte[]> entry in value)
                {
                    _buffer.Write_int(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_uint_boolean(Dictionary<uint, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, bool> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_uint_byte(Dictionary<uint, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, sbyte> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_uint_ubyte(Dictionary<uint, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, byte> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_uint_short(Dictionary<uint, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, short> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_uint_ushort(Dictionary<uint, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, ushort> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_uint_int(Dictionary<uint, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, int> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_uint_uint(Dictionary<uint, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, uint> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_uint_float(Dictionary<uint, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, float> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_uint_double(Dictionary<uint, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, double> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_uint_long(Dictionary<uint, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, long> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_uint_string(Dictionary<uint, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, string> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_uint_bytes(Dictionary<uint, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<uint, byte[]> entry in value)
                {
                    _buffer.Write_uint(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_float_boolean(Dictionary<float, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, bool> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_float_byte(Dictionary<float, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, sbyte> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_float_ubyte(Dictionary<float, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, byte> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_float_short(Dictionary<float, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, short> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_float_ushort(Dictionary<float, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, ushort> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_float_int(Dictionary<float, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, int> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_float_uint(Dictionary<float, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, uint> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_float_float(Dictionary<float, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, float> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_float_double(Dictionary<float, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, double> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_float_long(Dictionary<float, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, long> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_float_string(Dictionary<float, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, string> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_float_bytes(Dictionary<float, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<float, byte[]> entry in value)
                {
                    _buffer.Write_float(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_double_boolean(Dictionary<double, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, bool> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_double_byte(Dictionary<double, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, sbyte> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_double_ubyte(Dictionary<double, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, byte> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_double_short(Dictionary<double, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, short> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_double_ushort(Dictionary<double, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, ushort> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_double_int(Dictionary<double, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, int> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_double_uint(Dictionary<double, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, uint> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_double_float(Dictionary<double, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, float> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_double_double(Dictionary<double, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, double> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_double_long(Dictionary<double, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, long> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_double_string(Dictionary<double, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, string> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_double_bytes(Dictionary<double, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<double, byte[]> entry in value)
                {
                    _buffer.Write_double(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_long_boolean(Dictionary<long, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, bool> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_long_byte(Dictionary<long, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, sbyte> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_long_ubyte(Dictionary<long, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, byte> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_long_short(Dictionary<long, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, short> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_long_ushort(Dictionary<long, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, ushort> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_long_int(Dictionary<long, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, int> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_long_uint(Dictionary<long, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, uint> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_long_float(Dictionary<long, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, float> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_long_double(Dictionary<long, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, double> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_long_long(Dictionary<long, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, long> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_long_string(Dictionary<long, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, string> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_long_bytes(Dictionary<long, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<long, byte[]> entry in value)
                {
                    _buffer.Write_long(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_string_boolean(Dictionary<string, bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, bool> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_string_byte(Dictionary<string, sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, sbyte> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_string_ubyte(Dictionary<string, byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, byte> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_string_short(Dictionary<string, short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, short> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_string_ushort(Dictionary<string, ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, ushort> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_string_int(Dictionary<string, int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, int> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_string_uint(Dictionary<string, uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, uint> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_string_float(Dictionary<string, float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, float> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_string_double(Dictionary<string, double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, double> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_string_long(Dictionary<string, long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, long> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_string_string(Dictionary<string, string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, string> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_string_bytes(Dictionary<string, byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<string, byte[]> entry in value)
                {
                    _buffer.Write_string(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_bytes_boolean(Dictionary<byte[], bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], bool> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_bytes_byte(Dictionary<byte[], sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], sbyte> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_bytes_ubyte(Dictionary<byte[], byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], byte> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_bytes_short(Dictionary<byte[], short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], short> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_bytes_ushort(Dictionary<byte[], ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], ushort> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_bytes_int(Dictionary<byte[], int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], int> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_bytes_uint(Dictionary<byte[], uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], uint> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_bytes_float(Dictionary<byte[], float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], float> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_bytes_double(Dictionary<byte[], double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], double> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_bytes_long(Dictionary<byte[], long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], long> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_bytes_string(Dictionary<byte[], string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], string> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_bytes_bytes(Dictionary<byte[], byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.MAP);
            if (value.Count > 0)
            {
                foreach (KeyValuePair<byte[], byte[]> entry in value)
                {
                    _buffer.Write_bytes(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_map_boolean_pod<V>(Dictionary<bool, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<bool, V> entry in map)
                {
                    _buffer.Write_boolean(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_byte_pod<V>(Dictionary<sbyte, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<sbyte, V> entry in map)
                {
                    _buffer.Write_byte(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_ubyte_pod<V>(Dictionary<byte, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<byte, V> entry in map)
                {
                    _buffer.Write_ubyte(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_short_pod<V>(Dictionary<short, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<short, V> entry in map)
                {
                    _buffer.Write_short(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_ushort_pod<V>(Dictionary<ushort, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<ushort, V> entry in map)
                {
                    _buffer.Write_ushort(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_int_pod<V>(Dictionary<int, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<int, V> entry in map)
                {
                    _buffer.Write_int(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_uint_pod<V>(Dictionary<uint, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<uint, V> entry in map)
                {
                    _buffer.Write_uint(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_float_pod<V>(Dictionary<float, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<float, V> entry in map)
                {
                    _buffer.Write_float(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_double_pod<V>(Dictionary<double, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<double, V> entry in map)
                {
                    _buffer.Write_double(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_long_pod<V>(Dictionary<long, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<long, V> entry in map)
                {
                    _buffer.Write_long(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_string_pod<V>(Dictionary<string, V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<string, V> entry in map)
                {
                    _buffer.Write_string(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_bytes_pod<V>(Dictionary<byte[], V> map) where V : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<byte[], V> entry in map)
                {
                    _buffer.Write_bytes(entry.Key);
                    Write_pod(entry.Value);
                }
            }
        }

        public void Write_map_pod_boolean<K>(Dictionary<K, bool> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, bool> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_boolean(entry.Value);
                }
            }
        }

        public void Write_map_pod_byte<K>(Dictionary<K, sbyte> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, sbyte> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_byte(entry.Value);
                }
            }
        }

        public void Write_map_pod_ubyte<K>(Dictionary<K, byte> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, byte> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_ubyte(entry.Value);
                }
            }
        }

        public void Write_map_pod_short<K>(Dictionary<K, short> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, short> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_short(entry.Value);
                }
            }
        }

        public void Write_map_pod_ushort<K>(Dictionary<K, ushort> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, ushort> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_ushort(entry.Value);
                }
            }
        }

        public void Write_map_pod_int<K>(Dictionary<K, int> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, int> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_int(entry.Value);
                }
            }
        }

        public void Write_map_pod_uint<K>(Dictionary<K, uint> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, uint> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_uint(entry.Value);
                }
            }
        }

        public void Write_map_pod_float<K>(Dictionary<K, float> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, float> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_float(entry.Value);
                }
            }
        }

        public void Write_map_pod_double<K>(Dictionary<K, double> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, double> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_double(entry.Value);
                }
            }
        }

        public void Write_map_pod_long<K>(Dictionary<K, long> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, long> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_long(entry.Value);
                }
            }
        }

        public void Write_map_pod_string<K>(Dictionary<K, string> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, string> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_string(entry.Value);
                }
            }
        }

        public void Write_map_pod_bytes<K>(Dictionary<K, byte[]> map) where K : IPOD
        {
            if (map == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)map.Count, SType.MAP);
            if (map.Count > 0)
            {
                foreach (KeyValuePair<K, byte[]> entry in map)
                {
                    Write_pod(entry.Key);
                    _buffer.Write_bytes(entry.Value);
                }
            }
        }

        public void Write_list_boolean(List<bool> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (bool v in value)
                {
                    _buffer.Write_boolean(v);
                }
            }
        }

        public void Write_list_byte(List<sbyte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (sbyte v in value)
                {
                    _buffer.Write_byte(v);
                }
            }
        }

        public void Write_list_ubyte(List<byte> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (byte v in value)
                {
                    _buffer.Write_ubyte(v);
                }
            }
        }

        public void Write_list_short(List<short> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (short v in value)
                {
                    _buffer.Write_short(v);
                }
            }
        }

        public void Write_list_ushort(List<ushort> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (ushort v in value)
                {
                    _buffer.Write_ushort(v);
                }
            }
        }

        public void Write_list_int(List<int> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (int v in value)
                {
                    _buffer.Write_int(v);
                }
            }
        }

        public void Write_list_uint(List<uint> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (uint v in value)
                {
                    _buffer.Write_uint(v);
                }
            }
        }

        public void Write_list_float(List<float> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (float v in value)
                {
                    _buffer.Write_float(v);
                }
            }
        }

        public void Write_list_double(List<double> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (double v in value)
                {
                    _buffer.Write_double(v);
                }
            }
        }

        public void Write_list_long(List<long> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (long v in value)
                {
                    _buffer.Write_long(v);
                }
            }
        }

        public void Write_list_string(List<string> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (string v in value)
                {
                    _buffer.Write_string(v);
                }
            }
        }

        public void Write_list_bytes(List<byte[]> value)
        {
            if (value == null)
            {
                _buffer.WriteNull();
                return;
            }
            _buffer.WriteSize((uint)value.Count, SType.LIST);
            if (value.Count > 0)
            {
                foreach (byte[] v in value)
                {
                    _buffer.Write_bytes(v);
                }
            }
        }


        #endregion

    }
}
